﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ReticleTrigger_for_Window : MonoBehaviour {	
	private VRReticleTriggerItem vrReticleTriggerItem;//处理准星精度条触发的类变量
	private void Awake ()
    {   //要保证对象也有VRReticleTriggerItem脚本
        vrReticleTriggerItem = GetComponent<VRReticleTriggerItem> () ?? gameObject.AddComponent<VRReticleTriggerItem>() ;		
	}
	//对象使能（激活）时调用
	private void OnEnable()
	{
		//订阅事件
		vrReticleTriggerItem.OnTrigger += HandleTrigger;
	}

	//对象不使能（不激活）时调用
	private void OnDisable()
	{   //去掉订阅的事件
		vrReticleTriggerItem.OnTrigger -= HandleTrigger;	
	}

	//准星凝视进度条满了后，要触发的事件代码
	void HandleTrigger ()
    {   //调用游戏逻辑控制脚本中对应的public方法
        FindObjectOfType<GameManager>().OpenWindow ();
	}
}

